import { Injectable } from '@angular/core';
import { Resolve,ActivatedRouteSnapshot,RouterStateSnapshot } from '@angular/router';
import { Observable,of } from 'rxjs';
import { map, take, catchError }  from 'rxjs/operators';
import { HttpClient, HttpHeaders, HttpErrorResponse } from "@angular/common/http";
import { AuthTokenService } from '@services/auth-token.service';

@Injectable()
export class MyaccountResolver implements Resolve<Object> {

    constructor(private authTokenService:AuthTokenService,
                private http:HttpClient) {

    }
  
    resolve(route: ActivatedRouteSnapshot,state: RouterStateSnapshot): Observable<any>|Promise<any>|any {
      let url = '/scm/app/getBankAccountList.do';  
      let request = {
          "appuserid":this.authTokenService.getAppUserId()
      };
      return this.http.post(url,request).pipe(
        catchError((error)=>{
          return of(error);
        })
      );
    }
  }